<template>
<div>
  <div>
    <h1>新增药品信息</h1>
  </div>
  <el-form :model="medication" label-width="120px">
<!--    <el-form-item label="生产厂家">-->
<!--      <el-select v-model="medication.mfacturer" placeholder="请选择生产厂家">-->
<!--        <el-option label="全部" value="全部" />-->
<!--        <el-option label="阿里大药房" value="阿里大药房" />-->
<!--        <el-option label="京东大药房" value="京东大药房" />-->
<!--        <el-option label="同仁堂大药房" value="同仁堂大药房" />-->
<!--      </el-select>-->
<!--    </el-form-item>-->
    <el-form-item label="药品名">
      <el-input v-model="medication.mname" type="textarea" />
    </el-form-item>
    <el-form-item label="生产厂家">
      <el-input v-model="medication.mfacturer" type="textarea" />
    </el-form-item>
    <el-form-item label="价格">
      <el-input v-model="medication.price" type="textarea" />
    </el-form-item>
    <el-form-item label="生产日期">
      <el-date-picker v-model="medication.ctime" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" placeholder="请选择生产日期" style="width: 100%;" />
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="save">新增药品</el-button>
      <el-button>取消</el-button>
    </el-form-item>
  </el-form>
</div>
</template>

<script>
//去src/api路径下添加js文件
import { add } from '@/api/medication'
export default {
  data(){
    return{
      medication:{}
    }
  },
  methods:{
    save(){
      add(this.medication).then(res=>{
        if(res.code==0){
          this.$alert('亲，新增药品成功了！', '新增成功', {
            confirmButtonText: '确定',
            callback: action => {
              this.$message({
                type: 'info',
                message: `action: ${ action }`
              });
              this.medication={}
            }
          });
        }
      })
    }
  }
}
</script>

<style>

</style>
